package com.manor.paradise.activity

import android.content.Context
import android.content.Intent
import com.gyf.immersionbar.ktx.immersionBar
import com.manor.common.activity.AbsActivity
import com.manor.common.utils.KLog
import com.manor.common.utils.selected
import com.manor.paradise.R
import com.manor.paradise.bean.ParadiseInfoBean
import kotlinx.android.synthetic.main.activity_jz.*
import kotlinx.android.synthetic.main.lyb_activity_tm_level.*
import java.math.BigDecimal

class LybTmLevelActivity : AbsActivity() {
    var paradiseInfoBean: ParadiseInfoBean? = null;

    override fun getLayoutId() = R.layout.lyb_activity_tm_level

    override fun main() {
        super.main()
        setTopTitle("等级徽章", bgColor = R.color.white)
        immersionBar {
            statusBarColor(R.color.transparent)
            titleBar(mTitleBarLayout)
            statusBarDarkFont(true)
        }
        if (null != intent && null != intent.getSerializableExtra("jz")) {
            paradiseInfoBean = intent.getSerializableExtra("jz") as ParadiseInfoBean
        }

        paradiseInfoBean?.run {
            if (npc.compareTo(BigDecimal("1")) == 0) {//区域合伙人
                im_5.setImageResource(R.mipmap.pic_y_jz5)
                tv5.isSelected = true
            }
            if (npc.compareTo(BigDecimal("2")) == 0) {//市级合伙人
                im_6.setImageResource(R.mipmap.pic_y_jz6)
                tv6.isSelected = true
            }

            if(paradiseInfoBean?.bright.equals("2")){
                when (star) {
                    0 -> {
                        selected(mTmLevel1Layout, mTmLevel2Layout, mTmLevel3Layout, mTmLevel4Layout)
                    }
                    1 -> {
                        selected(mTmLevel2Layout, mTmLevel1Layout, mTmLevel3Layout, mTmLevel4Layout)
                    }
                    2 -> {
                        selected(mTmLevel3Layout, mTmLevel2Layout, mTmLevel1Layout, mTmLevel4Layout)
                    }
                    3 -> {
                        selected(mTmLevel4Layout, mTmLevel2Layout, mTmLevel3Layout, mTmLevel1Layout)
                    }
                }
            }else{
                when (star) {
                    0 -> {
                        mTmLevel1Layout.isSelected = true
                    }
                    1 -> {
                        mTmLevel1Layout.isSelected = true
                        mTmLevel2Layout.isSelected = true
                    }
                    2 -> {
                        mTmLevel1Layout.isSelected = true
                        mTmLevel2Layout.isSelected = true
                        mTmLevel3Layout.isSelected = true
                    }
                    3 -> {
                        mTmLevel1Layout.isSelected = true
                        mTmLevel2Layout.isSelected = true
                        mTmLevel3Layout.isSelected = true
                        mTmLevel4Layout.isSelected = true
                    }
                    4 -> {
                        mTmLevel1Layout.isSelected = true
                        mTmLevel2Layout.isSelected = true
                        mTmLevel3Layout.isSelected = true
                        mTmLevel4Layout.isSelected = true
                    }
                }
            }

        }
    }
    companion object {
        fun launch(context: Context, item: ParadiseInfoBean) {
            val intent = Intent(context, LybTmLevelActivity::class.java)
            intent.putExtra("jz", item)
            context.startActivity(intent)
        }
    }
}